package jaux.tank.generator.util;

import java.util.Locale;
import java.util.ResourceBundle;

public class TextUtil {

	private static TextUtil instance = null;
	private ResourceBundle bundle;
	private TextUtil() {
		setLocale(Locale.getDefault());
	}
	
	public static TextUtil getInstance() {
		if(instance == null) {
			instance = new TextUtil();
		}
		return instance;
	}
	
	public void setLocale(Locale locale) {
		bundle = ResourceBundle.getBundle("messages", locale);
		
	}
	
	public String getString(String key) {
		if(bundle == null || key ==null || !bundle.containsKey(key)) {
			return String.format("{{%s}}", key);
			
		}
		return   bundle.getString(key);
	}
	
	
	
}
